<!DOCTYPE html>
<html lang="en">
<head>
    <title></title>
    <link href="/css/css.css" rel="stylesheet" type="text/css" />
</head>
<body class="bj">
<section>
    <div class="head">
        <p class="head_top"></p>
        <div class="head_btn">
            <span class="head_1">文字直播间</span>
            <span class="head_2">注册账号</span>
            <div class="head_right">
                <span>我已注册，现在就</span>
                <a href="/login"><span>登陆</span></a>
            </div>
        </div>
    </div>
    <div class="body">
        <div class="biaodan1">
            <ul>
                <li>
                    <span><img src="img/user_03.png">用户名</span>
                    <input type="text" id="uid" />
                </li>
                <li>
                    <span><img src="img/szmm_03.png">设置密码</span>
                    <input type="password" id="pwd1" />
                </li>
                <li>
                    <span><img src="img/qrmm_03.png">确认密码</span>
                    <input type="password" id="pwd" />
                </li>
                <li>
                    <span><img src="img/xx_03.png">电子邮箱</span>
                    <input type="text" id="email" />
                </li>
            </ul>
        </div>
        <div class="checkbox">
            <ul>
                <li style="float: left;">
                    <label>
                        <input type="radio" class="checkbox1" name="type" value="1">
                        <span>注册分析师</span>
                    </label>
                </li>
                <li style="float: left;margin-left: 70px">
                    <label>
                        <input type="radio" class="checkbox1" name="type" value="2">
                        <span>注册会员</span>
                    </label>
                </li>
                <div class="clear"></div>
            </ul>
        </div>
        <div class="buttom">
            <a id="submit">提交</a>
        </div>
    </div>
</section>
<script type="text/javascript" src="/js/jquery-1.11.3.js"></script>
<script type="text/javascript" src="/layer/2.1/layer.js"></script>
<script type="text/javascript">
    $(function () {
        $("#submit").click(function () {
            var uid = $("#uid");
            var pwd1 = $("#pwd1");
            var pwd = $("#pwd");
            var email = $("#email");
            var type = $("input[name='type']:checked").val();
            if (uid.val() == '') {
                layer.msg('用户名不能为空', {icon: 5, time: 1000}, function () {uid.focus();});
                return false;
            } else if (pwd1.val() == '') {
                layer.msg('密码不能为空', {icon: 5, time: 1000}, function () {pwd1.focus();});
                return false;
            } else if (pwd.val() == '') {
                layer.msg('请确认密码', {icon: 5, time: 1000}, function () {pwd.focus();});
                return false;
            } else if (pwd.val() != pwd1.val()) {
                layer.msg('两次密码输入不一致', {icon: 5, time: 1000}, function () {pwd1.focus();});
                return false;
            } else if (email.val() == '') {
                layer.msg('请输入电子邮箱', {icon: 5, time: 1000}, function () {email.focus();});
                return false;
            } else if (!type) {
                layer.msg('请选择要注册的会员类型', {icon: 5, time: 1000});
                return false;
            } else {
                $.ajax({
                    type: 'post', dataType: 'json', cache: false,
                    url: '/do_reg_info',
                    data: {'uid': uid.val(), 'pwd': pwd.val(), 'email': email.val()},
                    success: function (data) {
                        if (data.status == 0) {
                            layer.msg('注册成功', {icon: 1, time: 1000}, function () {window.location.href = '/user';});
                        } else {
                            layer.msg(data.info, {icon: 2, time: 1000});
                        }
                    }
                });
            }
        });
    });
</script>
</body>
</html>